package zero.tech.games.dn.data.entity;

import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;

import zero.tech.core.data.KeyVal;
import zero.tech.core.util.StringHelper;
import zero.tech.games.dn.data.DnConfig;

public class DnMultiple {
	private final Map<Integer,Integer> dn_multiple=new HashMap<>();

	public DnMultiple(DnConfig dnConfig) {
		System.out.println(JSONObject.toJSONString(dnConfig));
		int niu11_multiple = dnConfig.getNiu11_multiple();
		int niu12_multiple = dnConfig.getNiu12_multiple();
		int niu13_multiple = dnConfig.getNiu13_multiple();
		int niu14_multiple = dnConfig.getNiu14_multiple();
		int niu15_multiple = dnConfig.getNiu15_multiple();
		int niu16_multiple = dnConfig.getNiu16_multiple();
		int niu17_multiple = dnConfig.getNiu17_multiple();
		int niu18_multiple = dnConfig.getNiu18_multiple();
		dn_multiple.put(11, niu11_multiple);
		dn_multiple.put(12, niu12_multiple);
		dn_multiple.put(13, niu13_multiple);
		dn_multiple.put(14, niu14_multiple);
		dn_multiple.put(15, niu15_multiple);
		dn_multiple.put(16, niu16_multiple);
		dn_multiple.put(17, niu17_multiple);
		dn_multiple.put(18, niu18_multiple);
		String niu_str=dnConfig.getNiu_str();
		String[] strs=niu_str.split(",");
		for(String str:strs) {
			String[] tmps=str.split("-");
			dn_multiple.put(Integer.valueOf(tmps[0]), Integer.valueOf(tmps[1]));
		}
	}

	public Map<Integer, Integer> getDn_multiple() {
		return dn_multiple;
	}

	public int getMaxMultile() {
		List<KeyVal<Integer, Integer>> list=StringHelper.parseMapToList(dn_multiple);
		Collections.sort(list,new Comparator<KeyVal<Integer, Integer>>() {

			@Override
			public int compare(KeyVal<Integer, Integer> o1, KeyVal<Integer, Integer> o2) {
				return o2.getV()-o1.getV();
			}
		});
		return list.get(0).getV();
	}
}
